<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        var a = 2;
        function f() {
            var im = document.getElementById("im");
            if (a==39)a=1;
            im.src ="image/"+(a++)+".jpg";
        }
    </script>
</head>
<body onload=" setInterval('f()',5000)">
    <img id="im" src="image/1.jpg"style="height: 400px;width: 700px">
</body>
</html>